Skip to content

[JEWEL-1276] Fix popup focus-stealing in JDialogRenderer#3476

Open
rock3r wants to merge 1 commit intoJetBrains:masterfrom
rock3r:sebp/JEWEL-1276_fix-standalone-popup-focus-stealing
Open

[JEWEL-1276] Fix popup focus-stealing in JDialogRenderer#3476
rock3r wants to merge 1 commit intoJetBrains:masterfrom
rock3r:sebp/JEWEL-1276_fix-standalone-popup-focus-stealing

Conversation

@rock3r
Copy link
Copy Markdown
Collaborator

@rock3r rock3r commented Apr 2, 2026

Focusable popups rendered via JDialogRenderer steal key-window status on macOS, causing the parent window's title bar and traffic-light buttons to grey out as if the window were inactive. This happens because focusableWindowState is true when setVisible(true) is called, making the JDialog the macOS key window and deactivating the parent.

Notice how with this PR the semaphore icons remain active:

image

Changes

  • Apply the same focusableWindowState toggle technique used in IntelliJ's AbstractPopup/DialogPopupWrapper: set focusableWindowState = false and isAutoRequestFocus = false synchronously before isVisible = true, then restore focusableWindowState = true via SwingUtilities.invokeLater. The popup shows without becoming the key window, but can still accept focus on explicit interaction.
  • Change the AWTEventListener keyboard gate from dialog.isActive to dialog.isVisible, so onKeyEvent/onPreviewKeyEvent callbacks fire without requiring the dialog to hold key-window status.

Release notes

Bug fixes

  • Fixed focusable popups stealing key-window status on macOS, which caused the parent window title bar to appear inactive when a popup was shown via JDialogRenderer.

@rock3r rock3r added the Jewel label Apr 2, 2026
@rock3r rock3r self-assigned this Apr 2, 2026
Copy link
Copy Markdown
Collaborator

@DanielSouzaBertoldi DanielSouzaBertoldi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides not understanding the MacOS quirk at play here, it works and it's the way JB has been doing for a while now so that's fine by me 😎

Prevent JDialog-backed popups from stealing key-window status on macOS,
which caused the parent window title bar and traffic-light buttons to
appear greyed out (inactive).

Apply the same focusableWindowState toggle technique used in IntelliJ's
AbstractPopup/DialogPopupWrapper: set focusableWindowState=false and
isAutoRequestFocus=false synchronously before setVisible(true), then
restore focusableWindowState=true via SwingUtilities.invokeLater. This
lets the popup show without becoming the macOS key window, while still
allowing it to accept focus on explicit user interaction.

Also change the AWTEventListener keyboard gate from dialog.isActive to
dialog.isVisible, so onKeyEvent/onPreviewKeyEvent callbacks fire without
requiring the dialog to be the key window.
@rock3r rock3r force-pushed the sebp/JEWEL-1276_fix-standalone-popup-focus-stealing branch from 27811ae to 15a7b33 Compare April 14, 2026 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants